SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
-- =============================================
-- Author:		Emanuel Santos
-- Create date: 23-01-2013
-- Description:	Subscrever evento
-- =============================================
CREATE PROCEDURE [ext].[sp_fe_addSubscreverEvento] 
	-- Add the parameters for the stored procedure here
	@id_vi int OUT, 
	@id_eu int OUT,
	@id_ev int,
	@nom varchar(50),
	@cont varchar(50),
	@email varchar(50),
	@euvou varchar(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO [ext].[visitante] ([nome],[contacto],[email])
	VALUES (@nom,@cont,@email)
	SET @id_vi = SCOPE_IDENTITY();
	
	INSERT INTO [ext].[euVou] ([descricao])
	VALUES (@euvou)
	SET @id_eu = SCOPE_IDENTITY();
	
	INSERT INTO [ext].[subscreverEvento] ([id_visitante],[id_euVou],[id_evento])
	VALUES (@id_vi,@id_eu,@id_ev)
END
GO
